<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

abstract class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    public function gethttps($url, $data=""){

      //1.初始化链接资源
      $curl = curl_init($url);

      //2.设置参数
      curl_setopt($curl,CURLOPT_POST,1);
      curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
      // curl_setopt($curl,CURLOPT_URL,$url);
      curl_setopt($curl,CURLOPT_HEADER,0);
      // curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
      // curl_setopt($crul,CURLOPT_SSL_VERIFYPEER,0);
      curl_setopt($curl,CURLOPT_POSTFIELDS,http_build_query($data));

      //3.发送请求
      $da = curl_exec($curl);

      //4.关闭请求资源
      curl_close($curl);

      //file_put_contents('./a.txt',$da);
      return $da;
    }
}
